/*!
 * OpenSocial jQuery Tabs 1.0.0
 * http://code.google.com/p/opensocial-jquery/
 *
 * Copyright(C) 2009-2010 Nakajiman Software Inc.
 * http://nakajiman.lrlab.to/
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
jQuery.fn.extend({

  tabs: function(fn) {
    return this.each(function() {

      var tabset = new gadgets.TabSet(null, null, this);
      tabset.alignTabs('left');

      $('> ul', this).find('> li > a').each(function(i) {
        var content = $('#' + this.href.split('#')[1]).get(0);
        tabset.addTab($(this).html(), {
          tooltip: this.title,
          contentContainer: content,
          callback: function () {
            if (fn) fn.apply(content, [i, content]);
          }
        });
      }).end().remove();

    });
  }

});
